<?php

namespace Beerus\Modules\DecoCompany\Actions;

use Encore\Admin\Actions\RowAction;
use Illuminate\Http\Request;
use Doraemon\model\DecoCompanyEvaluation;


class FoldEvaluation extends RowAction
{
    public $name = '折叠评价';
    const TOAST_ALERT = '确认将该条评价折叠嘛?折叠后将把该条评价隐藏!';

    public function handle($id)
    {
        $update_data['is_fold'] = DecoCompanyEvaluation::FOLD_HIDDEN;
        $evaluate_result = DecoCompanyEvaluation::updateInfo($id,$update_data);
        if ($evaluate_result){
            return $this->response()->success('折叠该评价成功(*^__^*)')->refresh();
        }else{
            return $this->response()->error('折叠该评价失败,请稍后重试o(TωT)o');
        }

    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }

        return $key;
    }

    public function dialog()
    {
        $this->confirm(self::TOAST_ALERT);
    }
}
